# File: src/mcp_server/resources/health_resource.py
# Purpose: Defines a simple health check MCP resource.

import logging
from typing import Optional

# Import the 'mcp' instance defined in src/mcp_server/app.py
# *** Corrected import path ***
from ..app import mcp

# Import common schema for response type
from ...schemas.common import StatusResponse
# Context type hint is needed if the function signature requires it
from ..context import Context

# Use core logger setup
from ...core.logging_setup import get_logger
logger = get_logger(__name__)

# Note: If health_check needs access to lifespan context (e.g., check DB connection),
# it would need the 'ctx: Context' parameter. However, parameterless URI resources
# in FastMCP might have nuances with context injection. For a simple check,
# keeping it parameterless is fine if context isn't needed.
# If context IS needed, the function signature becomes:
# async def health_check(ctx: Context) -> StatusResponse:
# And you'd access lifespan via get_server_context(ctx).lifespan_context
@mcp.resource("health://check", description="Simple server health check.")
def health_check() -> StatusResponse:
    """
    MCP Resource: Checks if the server is operational.
    URI: health://check
    """
    logger.info("Health check resource requested.")
    # Simple check doesn't need context here
    return StatusResponse(success=True, message="MCP Server is healthy!", details=None)

logger.debug("Health check resource registered.")